#region File Description
//-----------------------------------------------------------------------------
// Game.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.GamerServices;
using JiggleGame;

#endregion

namespace GopacarsNetworkPrototype
{
    /// <summary>
    /// Sample showing how to manage the different game states involved in
    /// implementing a networked game, with menus for creating, searching,
    /// and joining sessions, a lobby screen, and the game itself. This main
    /// game class is extremely simple: all the interesting stuff happens
    /// in the ScreenManager component.
    /// </summary>
    public class GopacarsNetworkPrototypeGame : Microsoft.Xna.Framework.Game
    {
        #region Fields

        GraphicsDeviceManager graphics;
        ScreenManager screenManager;

        DebugDrawer debugDrawer;
        Camera camera1;
        Camera camera2;
        Camera currentCamera;

        public DebugDrawer DebugDrawer
        {
            get { return debugDrawer; }
        }

        public Camera Camera1
        {
            get { return camera1; }
        }
        public Camera Camera2
        {
            get { return camera2; }
        }
        public Camera CurrentCamera
        {
            get { return currentCamera; }
        }
        #endregion

        #region Initialization


        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GopacarsNetworkPrototypeGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;

            // Create components.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);
            Components.Add(new MessageDisplayComponent(this));
            Components.Add(new GamerServicesComponent(this));

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen());
            screenManager.AddScreen(new MainMenuScreen());

            camera1 = new Camera(this, ((float)graphics.PreferredBackBufferWidth / 2) / (float)graphics.PreferredBackBufferHeight);
            camera2 = new Camera(this, ((float)graphics.PreferredBackBufferWidth / 2) / (float)graphics.PreferredBackBufferHeight);
            currentCamera = camera1;
            debugDrawer = new DebugDrawer(this);
            debugDrawer.Enabled = false;

            camera1.Position = new Vector3(0, 80, 0);
            camera1.Target = new Vector3(200, 1000, 200);
            camera2.Position = new Vector3(0, 80, 0);
            camera2.Target = new Vector3(200, 1000, 200);
            
            Components.Add(camera1);
            Components.Add(camera2);
            Components.Add(debugDrawer);
            debugDrawer.DrawOrder = 1;
        }


        #endregion

        #region Draw


        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);

            // The real drawing happens inside the screen manager component.
            base.Draw(gameTime);
        }


        #endregion
    }


    #region Entry Point

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static class Program
    {
        static void Main()
        {
            using (GopacarsNetworkPrototypeGame game = new GopacarsNetworkPrototypeGame())
            {
                game.Run();
            }
        }
    }

    #endregion
}
